<%@page import="com.alibaba.fastjson.JSONObject"%>
<%@page import="weaver.conn.RecordSetTrans"%>
<%@page import="com.alibaba.fastjson.JSONArray"%>
<%@page import="weaver.general.Util"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String workflowId = Util.null2String(request.getParameter("workFlowId"));
String nodeId = Util.null2String(request.getParameter("nodeId"));
String actionList = Util.null2String(request.getParameter("actionList"));

boolean flag = false;
try{
	JSONArray arr = JSONArray.parseArray(actionList);
	if(arr!=null){
		RecordSetTrans rst = new RecordSetTrans();
		rst.setAutoCommit(false);
		rst.executeSql("delete from workflowactionset where interfacetype = 3 and workflowid = '"+workflowId+"' and nodeid = '"+nodeId+"'");
		for(Object obj : arr){
			JSONObject json = (JSONObject)obj;		
			String actionname = Util.null2String(json.getString("actionname"));
			String nodelinkid = "0";
			String ispreoperator = Util.null2String(json.getString("ispreoperator"));
			String actionorder = Util.null2String(json.getString("actionorder"));
			String interfaceid = Util.null2String(json.getString("interfaceid"));
			String interfacetype = "3";
			String isused = json.getBoolean("isused")?"1":"0";
			if(
				!"".equals(actionname) && 
				!"".equals(interfaceid) && 
				!"".equals(actionorder)
			){
				String sql = "insert into workflowactionset(actionname,nodelinkid,ispreoperator,actionorder,interfaceid,interfacetype,isused,workflowid,nodeid) values('"+actionname+"','"+nodelinkid+"','"+ispreoperator+"','"+actionorder+"','"+interfaceid+"','"+interfacetype+"','"+isused+"','"+workflowId+"','"+nodeId+"') ";
				rst.executeSql(sql);
			}
		}
		flag = rst.commit();
	}
}catch(Exception e){}
JSONObject json = new JSONObject();
json.put("flag",flag);
out.print(json.toJSONString());

%>